/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package poo.biblioteca.vistas.editoriales;

import biblioteca.entidades.Pais;
import java.util.ArrayList;

/**
 *
 * @author Alex
 */
public class PnlEditorial extends javax.swing.JPanel {

    /**
     * Creates new form PnlEditorial
     */
    public PnlEditorial() {
        initComponents();
        txtNombreEditorial.requestFocus();
    }

    public void setIdEditorial (String idEditorial) {
        txtIdEditorial.setText(idEditorial);
    }
    
    public void setNombreEditorial (String nombreEditorial){
        txtNombreEditorial.setText(nombreEditorial);
    }
    
    public void addPaises (ArrayList<Pais> paises) {
        for (Pais pais : paises) {
            cmbPaises.addItem(pais);
        }
    }
    
    public String getNombreEditorial () {
        return txtNombreEditorial.getText();
    }
    
    public Pais getPaisSeleccionado() {
        return (Pais) cmbPaises.getSelectedItem();
    }
        
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtIdEditorial = new javax.swing.JTextField();
        lblIdEditorial = new javax.swing.JLabel();
        txtNombreEditorial = new javax.swing.JTextField();
        lblNombreEditorial = new javax.swing.JLabel();
        cmbPaises = new javax.swing.JComboBox();
        lblPais = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Datos de Editorial"));

        txtIdEditorial.setEditable(false);
        txtIdEditorial.setEnabled(false);

        lblIdEditorial.setText("Id Editorial:");

        lblNombreEditorial.setText("Nombre Editorial:");

        lblPais.setText("País:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIdEditorial)
                    .addComponent(lblNombreEditorial)
                    .addComponent(lblPais))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNombreEditorial)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtIdEditorial, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbPaises, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 122, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdEditorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdEditorial))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombreEditorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombreEditorial))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbPaises, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPais)))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cmbPaises;
    private javax.swing.JLabel lblIdEditorial;
    private javax.swing.JLabel lblNombreEditorial;
    private javax.swing.JLabel lblPais;
    private javax.swing.JTextField txtIdEditorial;
    private javax.swing.JTextField txtNombreEditorial;
    // End of variables declaration//GEN-END:variables

    void setPaisSeleccionado(Pais pais) {
        cmbPaises.setSelectedItem(pais);
    }

}
